<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form">
  <div class="mainBox">
    <div class="main-container">
      <div class="layui-form-item">
        <label class="layui-form-label">用户帐号</label>
        <div class="layui-input-block">
          <input type="text" name="username" lay-verify="required" placeholder="请输入用户帐号" autocomplete="off" class="layui-input">
        </div>
      </div>


      <div class="layui-form-item">
        <label class="layui-form-label">当前用户组</label>
        <div class="layui-input-block">
          <select name="group" lay-verify="required">
            {volist name="$group" id="vo"}
            <option value="{$vo.id}" {eq name="$default_group" value="$vo.id"}selected{/eq}>{$vo.group_name}</option>
            {/volist}
          </select>
        </div>
      </div>


      <div class="layui-form-item">
        <label class="layui-form-label">登录密码</label>
        <div class="layui-input-block">
          <input type="password" name="password"  placeholder="请输入密码"  lay-verify="required" autocomplete="off"  class="layui-input">
        </div>
      </div>

      <div class="layui-form-item">
        <label class="layui-form-label">重复密码</label>
        <div class="layui-input-block">
          <input type="password" name="repassword"  placeholder="请再次输入密码"  lay-verify="required" autocomplete="off"  class="layui-input">
        </div>
      </div>

      <div class="layui-form-item">
        <label class="layui-form-label">安全邮箱</label>
        <div class="layui-input-block">
          <input type="email" name="email"  placeholder="请输入密码邮箱账号 "  lay-verify="required" autocomplete="off"  class="layui-input">
        </div>
      </div>


    </div>
  </div>
  <div class="bottom">
    <div class="button-container">
      <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="save">
        <i class="layui-icon layui-icon-ok"></i>
        提交
      </button>
      <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
        <i class="layui-icon layui-icon-refresh"></i>
        重置
      </button>
    </div>
  </div>
</form>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
  layui.use(['form','jquery'],function(){
    let form = layui.form;
    let $ = layui.jquery;
    form.on('submit(save)', function(data){
      $.ajax({
        data:JSON.stringify(data.field),
        dataType:'json',
        contentType:'application/json',
        type:'post',
        success:function(res){
          //判断有没有权限
          if(res && res.code == 999){
            layer.msg(res.msg, {
              icon: 5,
              time: 2000,
            })
            return false;
          }else if(res.code == 200){
            layer.msg(res.msg,{icon:1,time:1000},function(){
              parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
              parent.layui.table.reload("user-table");
            });
          }else{
            layer.msg(res.msg,{icon:2,time:1000});
          }
        }
      })
      return false;
    });
  })
</script>
</body>
</html>